import { loginByWxOpenidApi } from "@/service/api.js";


const commonFn = function(){
 let unid = JSON.parse(localStorage.getItem("unid"))
 let openid = JSON.parse(localStorage.getItem("openid"))
 if(unid&&openid){
  loginByWxOpenidApi({
    wxOpenid:openid,
    unid:unid,
    source: 16,
   }).then(res=>{
     if(res.code==4000){
  console.log(11111)
      console.log(res) 
     let token = JSON.stringify(res.data);
      localStorage.setItem("token", token);
      console.log(token)
      // window.reload()
     }
     if(res.code==4002){
      //  console.log(222)
      //  this.$router.push({
      //    name:"login"
      //  })
      console.log(1)
     }
    
   })
 }
//  else{   
// //  let  userInfo_url="http://loulijuan6.natapp1.cc/#login"
// //   window.location.href = userInfo_url;
// //      }
//  this.$router.push({
//    name:"/login"
//  })}
  }
  //将方法暴露出来
  export default {
    commonFn
  }  